package org.hindusingles.thf.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Millionaire implements EntryPoint
{
	/**
	 * Create a remote service proxy to talk to the server-side Greeting
	 * service.
	 */
	private final GreetingServiceAsync greetingService =
	(
		GWT.create(GreetingService.class)
	);
	
	/**
	 * This is the entry point method.
	 */
	@Override
	public void onModuleLoad( )
	{
		final HTML serverResponseLabel = new HTML( );
		
		RootPanel.get("serverResponseContainer").add(serverResponseLabel);
		
		greetingService.greetServer
		(
			"",
			new AsyncCallback<String>( )
			{
				public void onFailure(Throwable caught)
				{
					serverResponseLabel.setHTML
					(
						caught.getMessage( )
					);
				}
				
				public void onSuccess(String serverResponse)
				{
					serverResponseLabel.setHTML(serverResponse);
				}
			}
		);
	}
}